package com.oa.core.exception;

import com.joneying.common.web.response.Resp;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice
public class GlobalControllerAdvice {

    @ResponseBody
    @ExceptionHandler(value = BusinessException.class)
    public Resp businessHandler(BusinessException e){
        //发生异常进行日志记录，写入数据库或者其他处理，此处省略
        return new Resp().failure(e.getMessage());
    }

    @ResponseBody
    @ExceptionHandler(value = DataIsEmptyException.class)
    public Resp dataIsEmptyHandler(DataIsEmptyException e){
        //发生异常进行日志记录，写入数据库或者其他处理，此处省略
        return new Resp().failure(e.getMessage());
    }
}
